package io.demo03;

import java.io.*;

/**
 * @author cyt
 * @create 2020-02-25 15:09
 */
public class DataStream {
    public static void main(String[] args) throws IOException {
        // 构造对象
        FileInputStream fin = new FileInputStream("f:\\1.png");
        DataInputStream datain = new DataInputStream(fin);

        FileOutputStream fout = new FileOutputStream("f:\\2.png");
        DataOutputStream dataout = new DataOutputStream(fout);

        int temp;
        try {
            int file1;
            while ((file1 = datain.read()) != -1) {
                System.out.println("" + file1);
            }

            while ((temp = datain.read()) != -1) {
                dataout.write(temp);
            }

            System.out.println("把文件一，写入到文件二中。");
        } catch (IOException e) {
            e.printStackTrace();
        }

        fin.close();
        fout.close();
        datain.close();
        dataout.close();
    }
}
